import request from '@/utils/request'

export function getServer() {
  return request({
    url: '/server/findAllServer',
    // queryServerPag
    method: 'get'
  })
}

export function getServerList(listQuery) {
  return request.get('/server/queryServerPag', { params: listQuery })
}

export function getMyTodoList(listQuery) {
  return request.get('/server/queryMyTodoList', { params: listQuery })
}

export function getMyApplication(listQuery) {
  return request.get('/server/queryMyApplication', { params: listQuery })
}

export function findByName(serverName) {
  return request({
    url: '/server/queryServerByName',
    method: 'get',
    params: {
      serverName
    }
  })
}

export function createServer(server) {
  return request.post('/server/addServer', server)
}

export function checkServerName(serverName) {
  return request({
    url: '/server/checkServerName',
    method: 'get',
    params: {
      serverName
    }
  })
}

export function updateServer(server) {
  return request.put('/server/updateServer', server)
}

export function deleteServer(serverName) {
  return request({
    url: '/server/deleteServer',
    method: 'delete',
    params: {
      serverName
    }
  })
}

export function approve(taskId, isApproval, variables) {
  const map = {
    taskId,
    isApproval,
    variables
  }
  return request.put('/server/approveServer', map)
}
